<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>充值沃币</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

</head>
<link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
<link rel="stylesheet" href="/css/common.css" media="all">
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15>
                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">昵称:</label>
                            <div class="layui-input-inline">
                                <input type="text" name="adminName" id="adminName" lay-verify="required"
                                       lay-verType="tips"
                                       class="layui-input" readonly='readonly'>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">充值沃币数:</label>
                            <div class="layui-input-inline">
                                <input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" name="monery" id="monery"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button id="chongzhi" class="layui-btn" lay-filter="demo1" lay-submit>充值
                                </button>
                                <button class="layui-btn layui-icon layui-icon-close" id="back">
                                    取消
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/js/layui/layui.all.js"></script>
<script type="text/javascript" src="/admin/js/token.js"></script>
</body>
<script>
    var adminid = 0;
    var $ = layui.$;
    var s = layui.data("smonery");
    $("#adminName").val(s.adminmonery.admin_name)
    $("#chongzhi").click(function () {

        $.ajax({
            url: "/admin/recharge/transfer",
            type: "post",
            data: {
                admin_id1: adminid,
                admin_money1: $("#monery").val(),
                admin_id:localStorage.getItem("admin_id")
            },
            success: function (result) {

                if (result.code == 200) {
                    layer.msg('充值成功', {
                        icon: 1,
                        time: 1000

                    })
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);    //关闭弹出层
                    }, 1000)
                    return
                }
                layer.msg(result.msg, {
                    icon: 2
                })
                setTimeout(function () {
                    $("#monery").val("")
                }, 3000)
            },
            error: function () {
                layer.msg('网络原因修改失败', {
                    icon: 2
                })
            }
        });

    })
    $(function () {
        $.ajax({
            url: "/admin/updateselct",
            data: {
                adminName: s.adminmonery.admin_name
            },
            type: "GET",
            success: function (result) {
                adminid = 0;
                adminid = result.data[0].admin_id;
            }
        })
    })

    $('#back').click(function () {
        var index = parent.layer.getFrameIndex(window.name) //获取窗口索引
        parent.layer.close(index)    //关闭弹出层
    })
</script>
</html>